package io.datajek.spring.basics.movierecommendersystem.lesson11;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Created with IntelliJ IDEA.
 *
 * @author : 浩东
 * @version : 1.5
 * @Project : movie-recommender-system
 * @Package : io.datajek.spring.basics.movierecommendersystem.lesson1
 * @ClassName : ContentBasedFilter.java
 * @createTime : 2021/9/17 16:42
 * @Description :     实现基于内容的过滤器的逻辑
 */

@Component
@Qualifier("CBF")
public class ContentBasedFilter implements Filter {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    public ContentBasedFilter() {
        logger.info("In ContentBasedFilter constructor method");
    }

    public String[] getRecommendations(String movie){
        //基于内容的过滤器的逻辑

        //return movie recommendations
        return new String[]{"Happy Feet","Ice Age","Shark Tale"};
    }

    @PostConstruct
    public void postConstruct(){
        //将电影加载到缓存中
        logger.info("In RecommenderImplementation postConstruct method");
    }

    @PreDestroy
    public void preDestroy(){
        //从缓存中清除电影
        logger.info("In ContentBasedFilter preDestroy method");
    }

}
